package Problem;

import java.util.Scanner;

//
// Created by ✎﹏ℳ๓独赏☆独醉 on 2024/1/22.
// 
public class 求时刻 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int hours = scan.nextInt();
        int minutes = scan.nextInt();
        int time = scan.nextInt();
        if(minutes + time >= 60){
            hours += (minutes + time) / 60;
            minutes = (minutes + time) % 60;
        }else {
            minutes += time;
        }
        System.out.println(hours);
        System.out.println(minutes);
    }
}
